package com.binc.testspring.study.nio.netty.encodeAndDecode;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * FileName: MyByteToLongEncoder
 * Autho: binC
 * Date:  2022/4/21 14:36
 */
public class MyByteToLongEncoder  extends MessageToByteEncoder<Long> {

    //编码方法   将Long类型的数据编码成byte数组
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, Long msg, ByteBuf byteBuf) throws Exception {
        byteBuf.writeLong(msg);
    }
}
